<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<title>商家入驻申请</title>
    <link rel="stylesheet" type="text/css" href="seller/css/webbase.css" />
    <link rel="stylesheet" type="text/css" href="seller/css/pages-register.css" />
    <script type="text/javascript" src="seller/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script type="text/javascript">
    	var vilidataSuccessNumber=0;
    	function getAgreement(status){//协议勾选监听
    		alert(vilidataSuccessNumber);
    		if(vilidataSuccessNumber>=19){//判断验证成功的信息是否等于19即表单的输入框数
    			if(status==true){//所有信息均以填完，判断协议是否勾选
    				document.getElementById("agree").innerHTML="";
    				document.getElementById("registerSeller").disabled=false;//设置注册按钮为可点击状态
    			}else{//未勾选协议
    				document.getElementById("agree").innerHTML="此为必勾选项，不勾选，不能进行注册";
    				document.getElementById("registerSeller").disabled=true;//设置注册按钮为不可点击状态
    			}
    		}else{//信息未填写完成，提示继续填写
    			document.getElementById("agree").innerHTML="你还有信息没有输入完呢？请完成没有填写的信息！";
    		}
    	}
    	function getStatus(name,propertyName,propertyValue){
    		var responseText="";
    		if(propertyValue==""){//输入框为空
    			responseText=propertyName+"不能为空！";
    			document.getElementById(propertyName).innerHTML = responseText;
    		}else{//输入框不为空
    			 if(name=="sellerId"||name=="nickName"||name=="licenseNumber"||name=="taNumber"){
    				if(name=="sellerId"){
    					if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(propertyValue)){
			     			 responseText=propertyName+"用户名不能有特殊字符";
			     			 document.getElementById(propertyName).innerHTML = responseText;
			   			 }else	if(/(^\_)|(\__)|(\_+$)/.test(propertyValue)){
			     			 responseText=propertyName+"用户名首尾不能出现下划线_";
			     			 document.getElementById(propertyName).innerHTML = responseText;
			   			 }else if(/^\d+\d+\d$/.test(propertyValue)){
			            	 responseText=propertyName+"用户名不能全为数字";
			             	 document.getElementById(propertyName).innerHTML = responseText;
			   			 }else{
			   			 	$.ajax({
    							type:"POST",
    							url:"registerVilidate.action",
    							data:{sellerId:propertyValue},
    							success:function(data){
    								if(data==true){
    									//在数据库中查询到,该字段不能进行注册
    									responseText=propertyName+"已存在";
    									document.getElementById(propertyName).innerHTML = responseText;
    								}else{
    									//在数据库中查找不到，可以进行注册
    									document.getElementById(propertyName).innerHTML = responseText;
    									//通过一个输入框验证，把协议的value值加一
    									vilidataSuccessNumber=vilidataSuccessNumber+1;
    								}
    							}
    						}); 
			   			 }
    				}
    				if(name=="nickName"){
    					$.ajax({
    						type:"POST",
    						url:"registerVilidate.action",
    						data:{nickName:propertyValue},
    						success:function(data){
    							if(data==true){
    								//在数据库中查询到,该字段不能进行注册
    								responseText=propertyName+"已存在";
    								document.getElementById(propertyName).innerHTML = responseText;
    							}else{
    								//在数据库中查找不到，可以进行注册
    								document.getElementById(propertyName).innerHTML = responseText;
    								//通过一个输入框验证，把协议的value值加一
    								vilidataSuccessNumber=vilidataSuccessNumber+1;
    							}
    						}
    					}); 
    				}
    				if(name=="licenseNumber"){
    			 		var reg=/^\d{15}$/;
    			 		if(!reg.test(propertyValue)){
    			 			responseText="请输入正确的营业执照15个纯数字";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}else{
    			 				$.ajax({
    							type:"POST",
    							url:"registerVilidate.action",
    							data:{licenseNumber:propertyValue},
    							success:function(data){if(data==true){
    									//在数据库中查询到,该字段不能进行注册
    									responseText=propertyName+"已存在";
    									document.getElementById(propertyName).innerHTML = responseText;
    								}else{
    									//在数据库中查找不到，可以进行注册
    									document.getElementById(propertyName).innerHTML = responseText;
    									//通过一个输入框验证，把协议的value值加一
    									vilidataSuccessNumber=vilidataSuccessNumber+1;
    								}
    							}
    						}); 
    			 		}
    				}
    				if(name=="taNumber"){
    					$.ajax({
    						type:"POST",
    						url:"registerVilidate.action",
    						data:{taNumber:propertyValue},
    						success:function(data){
    							if(data==true){
    								//在数据库中查询到,该字段不能进行注册
    								responseText=propertyName+"已存在";
    								document.getElementById(propertyName).innerHTML = responseText;
    							}else{
    								//在数据库中查找不到，可以进行注册
    								document.getElementById(propertyName).innerHTML = responseText;
    								//通过一个输入框验证，把协议的value值加一
    								vilidataSuccessNumber=vilidataSuccessNumber+1;
    							}
    						}
    					}); 
    				}
    			}else{
    				if(name=="password"){
    						var reg= /((?=.*[a-z])(?=.*\d)|(?=[a-z])(?=.*[#@!~%^&*])|(?=.*\d)(?=.*[#@!~%^&*]))[a-z\d#@!~%^&*]{8,20}/i;
		    				if(reg.test(propertyValue)){
		    				document.getElementById(propertyName).innerHTML = responseText;
		    				//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
		    			}else{
		    				responseText=propertyName+"是由8到20位数字字母组合或者数字特殊符号组合或者字母特殊符号组合，不能纯数字和纯字母和纯特殊字符";
		    				document.getElementById(propertyName).innerHTML = responseText;
		    			}
    			 	}else if(name=="mobile" || name=="linkmanMobile"){
    			 		var reg=/^1[34578][0-9]{9}$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="手机号不合法";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else if(name=="legalPersonCardId"){
    			 		var reg=/^[1-9]\d{5}(18|19|[23]\d)\d{2}(0[1-9]|1[0-2])([0-2][1-9]|10|20|30|31)\d{3}[\dX]$|^[1-9]\d{5}\d{2}(0[1-9]|1[0-2])([0-2][1-9]|10|20|30|31)\d{3}$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="请输入正确的身份证号";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else if(name=="telephone"){
    			 		var reg=/^\d{8}$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="输入正确的电话";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else if(name=="bankcardNum"){
    			 		var reg= /^([1-9]{1})(\d{14}|\d{18})$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    					    vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="请输入正确的银行卡号";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else if(name=="orgNumber"){
    			 		var reg=/^[\dA-Z]{8}[X\d]$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="输入正确的组织机构代码";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else if(name=="legalPerson" || name=="linkmanName"){
    			 		var reg=/^[\u4e00-\u9fa5]{2,5}|[a-zA-Z]{4,8}$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="姓名应在全英文4-8之间或者全汉字2-5之间";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else if(name=="bankUser"){
    			 		var reg=/^[\u4e00-\u9fa5]{4,8}$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="输入正确的银行名";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else if(name=="bankName"){
    			 		var reg=/^[\u4e00-\u9fa5]{5,15}$/;
    			 		if(reg.test(propertyValue)){
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 			//通过一个输入框验证，把协议的value值加一
    						vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 		}else{
    			 			responseText="输入正确的银行支行5-15位之间";
    			 			document.getElementById(propertyName).innerHTML = responseText;
    			 		}
    			 	}else{
    			 		document.getElementById(propertyName).innerHTML = responseText;
    			 		//通过一个输入框验证，把协议的value值加一
    					vilidataSuccessNumber=vilidataSuccessNumber+1;
    			 	}
    			}
    		}
    	} 
    </script>
</head>

<body>
	<div class="register py-container ">
		<!--head-->
		<div class="logoArea">
			<a href="" class="logo"></a>
		</div>
		<!--register-->
		<div class="registerArea">
			<h3>商家入驻申请<span class="go">我有账号，去<a href="seller/public/shoplogin.jsp" target="_blank">登陆</a></span></h3>
			<div class="info">
				<form class="sui-form form-horizontal" id="registerForm">
				
					<div class="control-group">
						<label class="control-label">登陆名（不可修改）：</label>
						<div class="controls">
							<input  id="sellerId" name="sellerId"  type="text" placeholder="登陆名" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">							
							<span id="登陆名" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">登陆密码：</label>
						<div class="controls">
							<input id="password" name="password" type="password" placeholder="登陆密码" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="登陆密码" style="color: Red"></span>
						</div>
					</div>
				
					<div class="control-group">
						<label class="control-label">店铺名称：</label>
						<div class="controls">
							<input id="nickName" name="nickName" type="text" placeholder="店铺名称" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="店铺名称" style="color: Red"></span>	
						</div>
					</div>
				
					<div class="control-group">
						<label class="control-label">公司名称：</label>
						<div class="controls">
							<input id="name" name="name" type="text" placeholder="公司名称" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="公司名称" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">公司手机：</label>
						<div class="controls">
							<input id="mobile" name="mobile" type="text" placeholder="公司手机" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="公司手机" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">公司电话：</label>
						<div class="controls">
							<input id="telephone" name="telephone" type="text" placeholder="公司电话" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="公司电话" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">公司详细地址：</label>
						<div class="controls">
							<input id="addressDetail" name="addressDetail" type="text" placeholder="公司详细地址" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="公司详细地址" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">联系人姓名：</label>
						<div class="controls">
							<input id="linkmanName" name="linkmanName" type="text" placeholder="联系人姓名" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="联系人姓名" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">联系人QQ：</label>
						<div class="controls">
							<input id="linkmanQq" name="linkmanQq" type="text" placeholder="联系人QQ" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="联系人QQ" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">联系人手机：</label>
						<div class="controls">
							<input id="linkmanMobile" name="linkmanMobile" type="text" placeholder="联系人手机" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="联系人手机" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">联系人EMAIL：</label>
						<div class="controls">
							<input id="linkmanEmail" name="linkmanEmail" type="text" placeholder="联系人EMAIL" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="联系人EMAIL" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">营业执照号：</label>
						<div class="controls">
							<input name="licenseNumber" type="text" placeholder="营业执照号" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="营业执照号" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">税务登记证号：</label>
						<div class="controls">
							<input id="taxNumber" name="taxNumber" type="text" placeholder="税务登记证号" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="税务登记证号" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">组织机构代码证：</label>
						<div class="controls">
							<input id="orgNumber" name="orgNumber" type="text" placeholder="组织机构代码证" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="组织机构代码证" style="color: Red"></span>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">法定代表人：</label>
						<div class="controls">
							<input id="legalPerson" name="legalPerson" type="text" placeholder="法定代表人" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="法定代表人" style="color: Red"></span>
						</div>
					</div>

					<div class="control-group">
						<label class="control-label">法定代表人身份证号：</label>
						<div class="controls">
							<input id="legalPersonCardId" name="legalPersonCardId" type="text" placeholder="法定代表人身份证号" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="法定代表人身份证号" style="color: Red"></span>
						</div>
					</div>	

					<div class="control-group">
						<label class="control-label">开户行名称：</label>
						<div class="controls">
							<input id="bankUser" name="bankUser" type="text" placeholder="开户行名称" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="开户行名称" style="color: Red"></span>
						</div>
					</div>

					<div class="control-group">
						<label class="control-label">开户行支行：</label>
						<div class="controls">
							<input id="bankName" name="bankName" type="text" placeholder="开户行支行" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="开户行支行" style="color: Red"></span>
						</div>
					</div>

					<div class="control-group">
						<label class="control-label">银行账号：</label>
						<div class="controls">
							<input id="bankcardNum" name="bankcardNum" type="text" placeholder="银行账号" class="input-xfat input-xlarge" onblur="getStatus(this.name,this.placeholder,this.value)">
							<span id="银行账号" style="color: Red"></span>
						</div>
					</div>					
					
					<div class="control-group">
						<label for="inputPassword" class="control-label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
						<div class="controls">
							<input id="agreement" name="m1" type="checkbox" value="2" onclick="getAgreement(this.checked)"><span>同意协议并注册  <a href="seller/public/sampling.jsp">《品优购商家入驻协议》</a></span>
							<span id="agree" style="color: Red"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label"></label>
						<div class="controls btn-reg">
							<input id="registerSeller" type="button" value="申请入驻" class="sui-btn btn-block btn-xlarge btn-danger"  target="_blank"  disabled="disabled" onclick="javascript:void(0)"/>
						</div>
					</div>
				</form>
				<div class="clearfix"></div>
			</div>
		</div>
		<!--foot-->
		<div class="py-container copyright">
			<ul>
				<li>关于我们</li>
				<li>联系我们</li>
				<li>联系客服</li>
				<li>商家入驻</li>
				<li>营销中心</li>
				<li>手机品优购</li>
				<li>销售联盟</li>
				<li>品优购社区</li>
			</ul>
			<div class="address">地址：北京市昌平区建材城西路金燕龙办公楼一层 邮编：100096 电话：400-618-4000 传真：010-82935100</div>
			<div class="beian">京ICP备08001421号京公网安备110108007702
			</div>
		</div>
	</div>

<script type="text/javascript">
	
	$("#registerSeller").click(function(){
		$.ajax({
			type:"POST",
			url:"register.action",
			data:$("#registerForm").serialize(),
			ache:false,
			success:function(data){
				if(data==true){//注册成功转向登录页面
					location.href="seller/public/shoplogin.jsp";
				}else{//注册失败请重新注册
					alert("注册失败请重新注册");
					location.href="seller/public/register.jsp";
				}
				
			}
		});
	});
</script>
<script type="text/javascript" src="operator/js/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="operator/js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="operator/js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="operator/js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="operator/js/pages/register.js"></script>
</body>

</html>